package com.happyass.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyRunner implements CommandLineRunner {
    @Value("${myurl}")
    private String myurl;
    @Value("${googleexcute}")
    private String googleexcute;
    @Value("${openurl}")
    private boolean openurl;
    @Value("${server.port}")
    private String port;
    @Value("${address}")
    private String address;
    public MyRunner() {
    }
    @Override
    public void run(String... args) throws Exception {
        if(openurl){
            String cmd = googleexcute +" http://"+ myurl+":"+port+address;
            Runtime run = Runtime.getRuntime();
            try{
                run.exec(cmd);
                System.out.println("启动浏览器程序成功");
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
